<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .gray {
            color: gray;
        }
        .black {
            color: black;
        }
        .box {
            width: 200px;
            height: 400px;
        }
        #input {
            background-color: white;
        }
        .list {
            display: block;
            list-style: none;
            width: 200px;
            height: 300px;
        }
    </style>
</head>
<body>
    <input type="text"><br>
    <input type="text"><br>
    <input type="text"><br>
    <input type="text"><br>
    <input type="text"><br>
    <input type="text"><br>
    <button>提交</button> 
    <script>
        var iputs = document.getElementsByTagName("input")
        for (i = 0; i < iputs.length;i++) {
            iputs[i].onfocus = function () {
                for (j = 0;j <iputs.length;j++) {
                    iputs[j].style.backgroundColor = ""
                }
                this.style.backgroundColor = "gray"
            }
            iputs[i].onblur = function() {
                this.style.backgroundColor = ""
            }
        }
    </script> 
</body>
</html>